package mx.forms;

import org.apache.log4j.Logger;

import groovy.lang.Script;
import javafx.application.Platform;
import javafx.scene.web.WebEngine;
import mx.groovy.GUtils;
import mx.setup.Setup;

public class Java {	
	WebEngine engine;
	Logger logger = Logger.getLogger(getClass());
	
	public Java(WebEngine en) {
		engine = en;
	}
	
	public String hello(String s) {
		return "hello " + s;
	}
	
	public Script groovy(String s) throws Exception {
		Script o = GUtils.createGroovy(s);
		o.getBinding().setVariable("_en", engine);
		return o;
	}
	
	public Object testGroovy() throws Exception {
		String filename =Setup.getPath("forms") + "/grid/DemoTest.groovy";
		Object o = GUtils.createGroovy(filename, "utf-8");
		return o;
	}
	
	public void debug(String line) throws Exception {
		logger.debug(line);
	}
	
	public void exit() {
		Platform.exit();
	}
}
